package com.asdan.seededu.web.controller;


import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.asdan.seededu.entity.security.SubProject;
import com.asdan.seededu.service.ProjectService;
import com.asdan.seededu.service.impl.ProjectServiceImpl;
import com.demo2do.core.web.interceptor.MenuSetting;

@Controller
@MenuSetting("menu-project")
@RequestMapping("projects")
public class ProjectController {
	/**
	 * Display project page
	 * 
	 * @return
	 */
	@RequestMapping("")
	public String projects() {
		return "projects";
	}

	@RequestMapping("/question.txt")
	public String file() {
		return "question.txt";
	}
	@RequestMapping(value="/add",method=RequestMethod.POST)
	public String addSubPro(String fpid ,String spid , Model model) {
		
		
		return "" ;
	}
	
	@RequestMapping(value="/showspList",method=RequestMethod.GET) 
	public String showspList(String fpid ,String spid,Model model){
		
		System.out.println("showspList");
		ProjectService ps = new ProjectServiceImpl() ; 
		List<SubProject> listPro  ;
		model.addAttribute("fpid",fpid) ;
		if(spid!=null&&!"".equals(spid)){
			listPro = ps.getProjects("", spid) ;
		}else{
			listPro = ps.getProjects(fpid, "") ;
		}
		
		if("1".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/silkroad1" ;
			}else{
				model.addAttribute("sl", listPro) ;
			}
		}else if("2".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/hainan1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("3".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/onlinebusinesssimulation1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("4".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/businesssimulation1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("5".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/aapt1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("6".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/aaptforeign1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("7".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/wyef1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("8".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/math1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("9".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/mathforeign1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
			
		}else if("10".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/mun1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
		}else if("11".equals(fpid)){
			if(spid!=null&&!"".equals(spid)){
				model.addAttribute("sp", listPro.get(0)) ;
				return "projects/minimba1";
			}else{
				model.addAttribute("sl", listPro) ;
			}
		}
		return "projects/subprojects" ;
		
		
	}	
}
